<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-if和v-else和 v-else-if的使用</title>
  </head>
  <body>
    <div id="app">
      <h2 v-if="score>=90">优秀</h2>
      <h2 v-else-if="score>80">良好</h2>
      <h2 v-else>及格</h2>

      <h3>{{result}}</h3>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          message: "hello",
          score: 99,
        },
        computed: {
          result() {
            let showMessage = "";
            if (this.score > 90) {
              showMessage = "优秀";
            } else if (this.score > 80) {
              showMessage = "良好";
            } else {
              showMessage = "及格";
            }
            return showMessage;
          },
        },
      });
    </script>
  </body>
</html>
